-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
HHH-18629 Fix inconsistent column alias generated while result class is used for placeholder #9075
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
647bd5e to
6517870
Compare
|
Ready to review @beikov |
| if ( resultEntityClass != null ) { | ||
| boolean exists = false; | ||
| for ( ResultBuilder existing : resultSetMapping.getResultBuilders() ) { | ||
| if ( resultEntityClass == existing.getJavaType() ) { | ||
| exists = true; | ||
| break; | ||
| } | ||
| } | ||
| if ( !exists ) { | ||
| addEntity( (Class<R>) resultEntityClass, LockMode.READ ); | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was more thinking of creating a ResultSetMapping on demand instead of altering the existing one to avoid interference with user configured mappings.
| if ( resultEntityClass != null ) { | |
| boolean exists = false; | |
| for ( ResultBuilder existing : resultSetMapping.getResultBuilders() ) { | |
| if ( resultEntityClass == existing.getJavaType() ) { | |
| exists = true; | |
| break; | |
| } | |
| } | |
| if ( !exists ) { | |
| addEntity( (Class<R>) resultEntityClass, LockMode.READ ); | |
| } | |
| } | |
| final ResultSetMapping mapping; | |
| if ( resultJavaType != null && resultSetMapping.isDynamic() && resultSetMapping.getNumberOfResultBuilders() == 0 ) { | |
| mapping = ResultSetMapping.resolveResultSetMapping( originalSqlString, true, getSessionFactory() ); | |
| mapping.addResultBuilder( | |
| getSessionFactory().getMappingMetamodel().isEntityClass( resultJavaType ) | |
| ? Builders.entityCalculated( StringHelper.unqualify( entityType.getName() ), entityType.getName(), LockMode.READ, getSessionFactory() ) | |
| : Builders.resultClassBuilder( resultClass, getSessionFactory() ) | |
| ); | |
| } | |
| else { | |
| mapping = resultSetMapping; | |
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amended as you suggested, please note resultEntityClass always is entity class or null.
|
Could you rebase this on current main and repush please? I'm having trouble doing it myself locally. You may have failures in |
|
Superseded by #9301 |
Alternative to #8971
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.
https://hibernate.atlassian.net/browse/HHH-18629